// Learn cc.Class:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

import PointRoom from "../../Entities/PointRoom";
import DealRoom from "../../Entities/DealRoom";

cc.Class({
    extends: cc.Component,

    properties: {
        indicatorFirstSeat:{
            default:null,
            type:cc.Node
        },

        comparePoker:{
            default:null,
            type:require("compare_poker")
        },

        statusLabel:{
            default:null,
            type:cc.Label
        }
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        this.indicatorFirstSeat.active = false
        this.statusLabel.string = ""
    },

    start () {

    },

    // update (dt) {},

    showIndicatorFirstSeat:function (isShow) {
        this.indicatorFirstSeat.active = isShow
    },

    isUser:function (user) {
        return this.playerInfo === user
    },

    startCountting:function (countSeconds) {
        this.countDownNode.active = true
        this._noticePlayed = false
        this._startCountting = true
        this.progressBar.node.active = true
        this.progressBar.progress = 1

        this.totalSecond = countSeconds
        this.nowSecond = countSeconds

        this.labelTotalTime.string = this.nowSecond
        this.labelNowTime.string = this.nowSecond
    },

    updateCountting:function (seconds) {
        if(!this.countDownNode.active){
            this.startCountting(Math.ceil(seconds))
        }else {
            this.changeTime(seconds)
        }
    },

    _setFaceGray:function () {
        if(!this._isWhite) return
        this._isWhite = false
        if(this.dropMask) this.dropMask.active = false
        this.faceMask.active = true
        // this.faceSprite.node.color = new cc.Color(90,90,90)
    },

    //设置为什么都不遮罩
    _setFaceWhite:function () {
        if(this._isWhite) return
        this.statusLabel.string = ""
        this._isWhite = true
        this.faceMask.active = false
        if(this.dropMask) this.dropMask.active = false
        // this.faceSprite.node.color = new cc.Color(255,255,255)
    },

    changeReadyState:function (state) {
        this.iconReady.active = state
    },

    _setFaceDrop:function () {
        if(!this._isWhite) return
        this._isWhite = false
        this.faceMask.active = false
        if(this.dropMask) this.dropMask.active = true
        // this.faceSprite.node.color = new cc.Color(90,90,90)
    },

    updateGameScore:function (newScore) {
        if(cc.gg.dataMgr.room instanceof PointRoom) return

        if(cc.gg.dataMgr.room instanceof DealRoom){
            this.labelPTSScore.string = "PTS:"+(240 + newScore)
        }else {
            this.labelPTSScore.string = "PTS:"+newScore
        }

        cc.log("User的分数实际为：",newScore)
        cc.log("将PTS分数更新为：",this.labelPTSScore.string)
    },
});
